//
//  LSZDynamicCommentDetailsVC.m
//  JKFuYinProject
//
//  Created by 九酷 on 2018/8/22.
//  Copyright © 2018年 LC. All rights reserved.
//

#import "LSZDynamicCommentDetailsVC.h"

@interface LSZDynamicCommentDetailsVC ()<UITableViewDelegate,UITableViewDataSource,UITextViewDelegate,UIGestureRecognizerDelegate>
@property(nonatomic,assign) NSInteger page;
@property(nonatomic,strong) NSMutableArray * mutArrayData;


@property(nonatomic,strong) UITableView * tableViewAll;
//评价条
@property(nonatomic,strong) UIView * lowView;
@property(nonatomic,strong) UITextView * textView;
@property(nonatomic,strong) UILabel * uilabel;

//长按的是第一个区的第几行
@property(nonatomic,assign) NSInteger indexNum;

@end

@implementation LSZDynamicCommentDetailsVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"动态";
    self.mutArrayData = [[NSMutableArray alloc]init];
    self.tableViewAll = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight-48) style:UITableViewStyleGrouped];
    self.tableViewAll.delegate = self;
    self.tableViewAll.dataSource = self;
    self.tableViewAll.separatorColor = divider;
    self.tableViewAll.estimatedRowHeight =0;
    self.tableViewAll.estimatedSectionFooterHeight =0;
    self.tableViewAll.estimatedSectionHeaderHeight =0;
    self.tableViewAll.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.view addSubview:self.tableViewAll];
    self.page = 1;
    [self initWithDynamicCommentDetailsWithPage:self.page];
    [self.tableViewAll registerClass:[LSZBasicInformationCollectionViewCell class] forCellReuseIdentifier:@"LSZBasicInformationCollectionViewCell"];
    [self.tableViewAll registerClass:[LSZBasicInformationCollectionViewCell class] forCellReuseIdentifier:@"LSZBasicInformationCollectionViewCell"];
    [self.tableViewAll registerClass:[LSZAddMusicCollectionViewCell class] forCellReuseIdentifier:@"LSZAddMusicCollectionViewCell"];
    [self.tableViewAll registerClass:[LSZAppraiseTableViewCell class] forCellReuseIdentifier:@"LSZAppraiseTableViewCell"];

    [self.tableViewAll registerClass:[LSZHeaderLabelCell class] forHeaderFooterViewReuseIdentifier:@"LSZHeaderLabelCell"];
    [LSZSpecialPackaging initWithAppraise:self.view share:1 :^(UIView * lowView, UITextView * textView, UILabel * label, UIButton * but, UIImageView * imageShare) {
        textView.delegate = self;
        self.lowView = lowView;
        //        self.lowView.hidden = YES;
        self.textView = textView;
        label.text = @"写评论....";
        self.uilabel = label;
        imageShare.image = [UIImage imageNamed:@""];
        [imageShare tapGesture:^(UIGestureRecognizer *ges) {
            [self rightBtnDynamicCommentDetails];
        }];
        [but setTitleColor:titleColorLSZ forState:UIControlStateNormal];
        [but setTitle:@"发送" forState:UIControlStateNormal];
        [but addTarget:self action:@selector(rightBtnDynamicCommentDetails) forControlEvents:UIControlEventTouchUpInside];
    }];
    //增加监听，当键盘出现或改变时收出消息
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(keyboardWillShowDetails:)
                                                 name:UIKeyboardWillShowNotification
                                               object:nil];
    //增加监听，当键退出时收出消息
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(keyboardWillHideDetails:)
                                                 name:UIKeyboardWillHideNotification
                                               object:nil];
    [self.view tapGesture:^(UIGestureRecognizer *ges) {
        [self judgeByCurrentStatus];
    }];

    self.tableViewAll.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
        self.page = 1;
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            [self initWithDynamicCommentDetailsWithPage :self.page];
            [self.tableViewAll.mj_header endRefreshing];
        });
    }];
    self.tableViewAll.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
        self.page++;
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            [self initWithDynamicCommentDetailsWithPage:self.page];
            [self.tableViewAll.mj_footer endRefreshing];
        });
    }];
    UIButton *leftbutton=[[UIButton alloc]initWithFrame:CGRectMake(30, 0, 60, 38)];
    [leftbutton setImage:[UIImage imageNamed:@"动态_白点"] forState:UIControlStateNormal];
    [leftbutton addTarget:self action:@selector(clickMoveReport) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *rightitem=[[UIBarButtonItem alloc]initWithCustomView:leftbutton];
    self.navigationItem.rightBarButtonItem=rightitem;

}
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
    // 若为UITableViewCellContentView（即点击了tableViewCell），则不截获Touch事件
    if ([NSStringFromClass([touch.view class]) isEqualToString:@"UITableViewCellContentView"]) {
        return NO;
    }
    return  YES;
}
-(void)clickSingleDynamic
{
    [self.view endEditing:YES];
}
//当键盘出现或改变时调用
- (void)keyboardWillShowDetails:(NSNotification *)aNotification
{
    //获取键盘的高度
    NSDictionary *userInfo = [aNotification userInfo];
    NSValue *aValue = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];
    CGRect keyboardRect = [aValue CGRectValue];
    int height = keyboardRect.size.height;
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.3];
    self.tableViewAll.frame = CGRectMake(0, 0, ScreenWidth, ScreenHeight-self.lowView.frame.size.height-height);
    self.lowView.frame = CGRectMake(0, ScreenHeight-self.lowView.frame.size.height-height, ScreenWidth, self.lowView.frame.size.height);
    [UIView commitAnimations];
}
//当键退出时调用
- (void)keyboardWillHideDetails:(NSNotification *)aNotification{
    [self keyboardWhereabouts];
}
-(void)keyboardWhereabouts
{
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.3];
    self.tableViewAll.frame = CGRectMake(0, 0, ScreenWidth, ScreenHeight- self.lowView.frame.size.height);
    self.lowView.frame = CGRectMake(0, ScreenHeight-self.lowView.frame.size.height, ScreenWidth, self.lowView.frame.size.height);
    [self clickSingleDynamic];
    [UIView commitAnimations];
}
#pragma mark - 判断键盘的状态
-(void)judgeByCurrentStatus
{
    if(self.tableViewAll.frame.size.height < ScreenHeight- self.lowView.frame.size.height){
        [self keyboardWhereabouts];
    }
}
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
    NSString * strLong = [textView.text stringByReplacingCharactersInRange:range withString:text];
    if (strLong.length == 0) {
        self.uilabel.hidden = NO;
    }else{
        if (strLong.length > 0 && self.uilabel.hidden == NO) {
            self.uilabel.hidden = YES;
        }
    }
    if ([text isEqualToString:@"\n"]){ //判断输入的字是否是回车，即按下return
        //在这里做你响应return键的代码
        [self initWithUsersCommentOnResources:strLong];
        [self clickSingleDynamic];
        return NO; //这里返回NO，就代表return键值失效，即页面上按下return，不会出现换行，如果为yes，则输入页面会换行
    }
    return YES;
}

-(void)rightBtnDynamicCommentDetails
{
    [self initWithUsersCommentOnResources:self.textView.text];
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 0.00001;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    if(section == 0){
        return [LSZSpecialPackaging initWithReturnsthesizeOf:40 :5];
    }
    return 0.00001;
}
-(UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    LSZHeaderLabelCell * cell = [tableView dequeueReusableHeaderFooterViewWithIdentifier:@"LSZHeaderLabelCell"];
    if(section == 0){
        if(self.mutArrayData.count == 0){
            cell.label.text = @"暂无回复";
        }else{
            cell.label.text = @"全部回复";
        }
    }else{
        cell.label.hidden = YES;
    }
    return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0) {
        if(indexPath.row == 0){
            float A = [LSZSpecialPackaging initWithReturnsthesizeOf:13.5 :0.5];
            int C;
            if (ScreenWidth == 320) {
                C = 70;
            }else if(ScreenWidth == 375){
                C = 77;
            }else {
                C = 85;
            }
            NSString * string = [NSString stringWithFormat:@"%@%@",self.AllDynamicListsMg.theme_content,self.AllDynamicListsMg.content];
            CGFloat sizeImage = [LSZSpecialPackaging initWithReturnsthesizeOf:45 :5];
            CGFloat height;
            if ([string isEqualToString:@""]) {
                height = 0;
            }else{
                height =  [LSZSpecialPackaging caculateHeightOfText:ScreenWidth-sizeImage-25 height:ScreenHeight font:A :string];
            }
            return  height-10+C;
        }else if(indexPath.row == 1){
            CGFloat heightA = [LSZSpecialPackaging initWithReturnsthesizeOf:60 :5];

            CGFloat wids = (ScreenWidth-30-heightA)/3;
            if(self.AllDynamicListsMg.arrayImages.count == 0){
                return  0.00001;
            }
            else if (self.AllDynamicListsMg.arrayImages.count == 1) {
                return (ScreenWidth-30-heightA)/2+10;
            }else{
                CGFloat heigth ;
                if(self.AllDynamicListsMg.arrayImages.count%3 == 0){
                    heigth =  (self.AllDynamicListsMg.arrayImages.count/3)*(wids+10)+10;
                }else{
                    heigth =  (self.AllDynamicListsMg.arrayImages.count/3+1)*(wids+10)+10;
                }
                if (self.AllDynamicListsMg.arrayImages.count>6) {
                    return heigth+10;
                }else{
                    return heigth;
                }
            }
        }else if (indexPath.row == 2){
            if (self.AllDynamicListsMg.resources_name.length ==0) {
                return 0.0001;
            }else{
                return  [LSZSpecialPackaging initWithReturnsthesizeOf:60 :5];
            }
        }else{
            return 0.0001;
        }
    }else{
        LSZDynamicCommentDetailsMg * manager = nil;
        manager = self.mutArrayData[indexPath.row];
        CGFloat intFont = [LSZSpecialPackaging initWithReturnsthesizeOf:14 :0.5];
        CGFloat height = [LSZSpecialPackaging caculateHeightOfText:ScreenWidth-30 height:10000 font:intFont :manager.content];
        int count;
        if([NSStr(manager.comment_num) isEqualToString:@"0"]||NSStr(manager.comment_num).length == 0||[NSStr(manager.comment_num) isEqualToString:@""]){
            count  = 0;
        }else{
            count = 1;
        }
        if (ScreenWidth == 320) {
            //5
            return height+56+count*29;
        }else if(ScreenWidth == 375){
            // 6 7
            return height+60+count*32.5;
        }else {
            //plus
            return height+64+count*34;
        }
    }
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section == 0) {
         return 3;
    }else{
        return self.mutArrayData.count;
    }
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    __weak typeof(self) weakSelf = self;
    if (indexPath.section == 0) {
        if (indexPath.row == 0) {
            LSZBasicInformationCollectionViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"LSZBasicInformationCollectionViewCell" forIndexPath:indexPath];
            cell.AllDynamicListsMg = weakSelf.AllDynamicListsMg;
            [cell.imageHeader tapGesture:^(UIGestureRecognizer *ges) {
                LSZPersonalInformationPageVC * vc = [[LSZPersonalInformationPageVC alloc]init];
                vc.uid =weakSelf.AllDynamicListsMg.uid;
                vc.imageViewHeader = weakSelf.AllDynamicListsMg.avatar;
                [weakSelf.navigationController pushViewController:vc animated:YES];
            }];
            [cell.butFocusOn tapGesture:^(UIGestureRecognizer *ges) {
                [weakSelf clickButFocusOnDetaill:weakSelf.AllDynamicListsMg.uid :indexPath.section :weakSelf.AllDynamicListsMg];
            }];
            NSString * string = [NSString stringWithFormat:@"%@%@",weakSelf.AllDynamicListsMg.theme_content,weakSelf.AllDynamicListsMg.content];
            CGFloat A = [LSZSpecialPackaging initWithReturnsthesizeOf:13.5 :0.5];
            CGFloat sizeImage = [LSZSpecialPackaging initWithReturnsthesizeOf:45 :5];
            CGFloat height = [LSZSpecialPackaging caculateHeightOfText:ScreenWidth-25-sizeImage height:ScreenHeight font:A :string];
            CGRect rect = cell.labelTitle.frame;
            rect.size.height = height-10;
            cell.labelTitle.frame = rect;
            cell.selectionStyle = UITableViewCellSelectionStyleNone ;
            return cell;
        }else if (indexPath.row == 1){
            LSZImageViewFocusOnTableViewCell * cell = [[LSZImageViewFocusOnTableViewCell alloc]initWithImageViewFocusOn:weakSelf.AllDynamicListsMg.arrayImages];
            cell.selectionStyle = UITableViewCellSelectionStyleNone ;
            return cell;
        }else if (indexPath.row == 2){
            if (weakSelf.AllDynamicListsMg.resources_name.length ==0) {
                UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
                if (!cell) {
                    cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
                }
                cell.selectionStyle = UITableViewCellSelectionStyleNone ;
                return cell;
            }
            LSZAddMusicCollectionViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"LSZAddMusicCollectionViewCell" forIndexPath:indexPath];
            cell.AllDynamicListsMg = weakSelf.AllDynamicListsMg;
            [cell.contentView tapGesture:^(UIGestureRecognizer *ges) {
                [self AudioPlaybackAlsoAlbumJump:indexPath];
            }];
            [cell.labelTitle tapGesture:^(UIGestureRecognizer *ges) {
                [self AudioPlaybackAlsoAlbumJump:indexPath];
            }];  [cell.labelAuthor tapGesture:^(UIGestureRecognizer *ges) {
                [self AudioPlaybackAlsoAlbumJump:indexPath];
            }];  [cell.imageViewIcon tapGesture:^(UIGestureRecognizer *ges) {
                [self AudioPlaybackAlsoAlbumJump:indexPath];
            }];
            cell.contentView.userInteractionEnabled = YES;
            cell.selectionStyle = UITableViewCellSelectionStyleNone ;
            return cell;
        }else{
            UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
            if (!cell) {
                cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
            }
            cell.selectionStyle = UITableViewCellSelectionStyleNone ;
            return cell;
        }
    }else{
        LSZAppraiseTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"LSZAppraiseTableViewCell" forIndexPath:indexPath];
        LSZDynamicCommentDetailsMg * manager = nil;
        manager = weakSelf.mutArrayData[indexPath.row];
        cell.dynamicCommentDetailsMg = manager;

        [cell.imageViewHeader tapGesture:^(UIGestureRecognizer *ges) {
            LSZPersonalInformationPageVC * vc = [[LSZPersonalInformationPageVC alloc]init];
            vc.uid =manager.uid;
            vc.imageViewHeader = manager.avatar;
            [weakSelf.navigationController pushViewController:vc animated:YES];
        }];
        cell.butZan.tag = indexPath.row +1;
        [cell.butZan addTarget:self action:@selector(clickDynamicZan:) forControlEvents:UIControlEventTouchUpInside];
        [cell.labelZanNumber tapGesture:^(UIGestureRecognizer *ges) {
            [weakSelf clickDynamicZanManager:manager row:indexPath.row];
        }];
        [cell.imageViewShou tapGesture:^(UIGestureRecognizer *ges) {
            [weakSelf clickDynamicZanManager:manager row:indexPath.row];
        }];
        [cell tapGesture:^(UIGestureRecognizer *ges) {
            [weakSelf tapNextPage:manager];
        }];
        //分割线
        CGRect rect = cell.viewLow.frame;
        rect.origin.y = cell.frame.size.height-0.3;
        cell.viewLow.frame = rect;
        //设置长按
        UILongPressGestureRecognizer *longPressGR = [[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(clickReport:)];
        //设定最小的长按时间 按不够这个时间不响应手势
        longPressGR.minimumPressDuration = 0.7;
        [cell addGestureRecognizer:longPressGR];
        cell.selectionStyle = UITableViewCellSelectionStyleNone ;
        return cell;
    }
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(indexPath.section == 0 &&indexPath.row == 2){
        [self AudioPlaybackAlsoAlbumJump:indexPath];
    }
    if (self.mutArrayData.count > indexPath.row && indexPath.section == 1) {
        LSZDynamicCommentDetailsMg * manager = nil;
        manager = self.mutArrayData[indexPath.row];
        [self tapNextPage:manager];

    }
}
#pragma mark - 音频播放还是专辑的跳转
-(void)AudioPlaybackAlsoAlbumJump :(NSIndexPath *)indexPath
{
    LSZAllDynamicListsMg * mg = nil;
    mg = self.AllDynamicListsMg;
    NSString * str = [[NSString alloc]init];
    NSString * id_id_str = [[NSString alloc]init];
    if ([mg.type isEqualToString:@"2"]) {
        str = @"/Music/get_url";
    }else if ([mg.type isEqualToString:@"5"]){
        str = @"/Music/artist";
    }else{
        str = @"/Music/album";
    }
    id_id_str = mg.resources_id;
    [LSZRequestResolutionDic dynamicGetsAlbumArtistSongDataBasedOn:id_id_str URL:str type:mg.type :^(BOOL isOk, NSString * string, LSZNewAudioHomepageManager * manager) {
        if (isOk == YES) {
            if ([mg.type isEqualToString:@"2"]) {
                [LCUtils lcListPlayWithLSZNewAudioHomepageManager:manager];
            }else{
                LSZNewAudioPlayImageAndTableViewVC * vc = [[LSZNewAudioPlayImageAndTableViewVC alloc]init];
                LSZNewAudioHomepageMg * audioMg = nil;
                audioMg = manager.arrayData[0];
                [LCUtils albumArtistDetailsInterfaceJump:vc audioMg:audioMg typeComeWhere:@"1"];
                vc.lastPageNumberRow = [NSString stringWithFormat:@"%ld",(long)indexPath.row];
                vc.lastSection = [NSString stringWithFormat:@"%ld",(long)indexPath.section-1];
                [self.navigationController pushViewController:vc animated:YES];
            }
        }
    }];
}
#pragma mark - 对评论点赞
-(void)clickDynamicZan:(UIButton *)but
{
    if([[_UserM usercode] isEqualToString:@""]){
        pushAccLoginVC;
        return;
    }
    LSZDynamicCommentDetailsMg * manager = nil;
    manager = self.mutArrayData[but.tag-1];
    [self clickDynamicZanManager:manager row:but.tag-1];
}
#pragma mark - 对评论点赞
-(void)clickDynamicZanManager :(LSZDynamicCommentDetailsMg*)mg row:(NSInteger)row
{
    if([[_UserM usercode] isEqualToString:@""]){
        pushAccLoginVC;
        return;
    }
    NSString * ck = [[NSString alloc]init];
    NSString * mode = [[NSString alloc]init];
    if ([mg.is_admire isEqualToString:@"0"]) {
        ck = @"0";//点赞
        mode = @"";
    }else{
        ck = @"";//点赞
        mode = @"1";//取消点赞
    }
    [LSZRequestData theDynamicPointOfPraise:mg.id_id type:@"2" ck:ck mode:mode :^(BOOL isOk, NSString * string, NSDictionary * dic) {
        if (isOk == YES) {
            if([ck isEqualToString:@"0"]){
                mg.is_admire = @"1";
                mg.admire_num = [NSString stringWithFormat:@"%ld",(long)([mg.admire_num integerValue]+1)];
                [self initWithtring:@"点赞成功!"];
            }else{
                mg.is_admire = @"0";
                mg.admire_num = [NSString stringWithFormat:@"%ld",(long)([mg.admire_num integerValue]-1)];
                [self initWithtring:@"取消点赞!"];
            }
            LSZAppraiseTableViewCell * cell = (LSZAppraiseTableViewCell *)[self.tableViewAll cellForRowAtIndexPath:[NSIndexPath indexPathForRow:row  inSection:1]];
            if([mode isEqualToString:@"1"]){
                cell.imageViewShou.image = [UIImage imageNamed:@"点赞"];
            }else{
                cell.imageViewShou.image = [UIImage imageNamed:@"我的_签到_留言_已点赞"];
            }
            cell.labelZanNumber.text = mg.admire_num;
        }else{
            [self initWithtring:string];
        }
    }];
}
#pragma mark- 进入评论详情界面
-(void)tapNextPage :(LSZDynamicCommentDetailsMg*)manager
{
    LSZDynamicDetailsEvaluationViewController * vc = [[LSZDynamicDetailsEvaluationViewController alloc]init];
    vc.dynamicCommentDetailsMg = manager;
    vc.tid = self.AllDynamicListsMg.id_id;
    [self.navigationController pushViewController:vc animated:YES];
}
#pragma mark - 关注
-(void)clickButFocusOnDetaill :(NSString *)uid :(NSInteger)section :(LSZAllDynamicListsMg *)mg
{
    if([[_UserM usercode] isEqualToString:@""]){
        pushAccLoginVC;
    }else{
        [LSZRequestData payAttentionToOthers:uid Ck:@"0" mode:@"0" :^(BOOL isOk, NSString * str, NSDictionary * dic) {
            if (isOk == YES) {
                [self initWithtring:@"关注成功!"];
                LSZBasicInformationCollectionViewCell * cell = (LSZBasicInformationCollectionViewCell *)[self.tableViewAll cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0  inSection:section]];
                [cell.butFocusOn setTitle:@"已关注" forState:UIControlStateNormal];
                cell.butFocusOn.backgroundColor =  partialShallow;
                cell.butFocusOn.userInteractionEnabled = NO;
            }else{
                [self initWithtring:str];
            }
        }];
    }
}
#pragma mark - 获取资源数据
-(void)initWithDynamicCommentDetailsWithPage :(NSInteger)page
{
    __weak typeof(self) weakSelf = self;
    [LSZRequestResolutionDic dynamicCommentDetails:@"" tid:self.AllDynamicListsMg.id_id comment_id:@"" selfUser:@"" page:[NSString stringWithFormat:@"%ld",(long)page] :^(BOOL isOk, NSString * string, LSZDynamicCommentDetailsManager * manager) {
        if (isOk == YES) {
            if (page == 1) {
                [weakSelf.mutArrayData removeAllObjects];
                [weakSelf.mutArrayData addObjectsFromArray:manager.arrayData];
                if (manager.arrayData.count == 0) {
                    weakSelf.tableViewAll.mj_footer.hidden = YES;
                }
            }else{
                [weakSelf.mutArrayData addObjectsFromArray:manager.arrayData];
            }
            [weakSelf.tableViewAll reloadData];
        }else{
            [weakSelf initWithtring:string];
        }
    }];
}
#pragma mark - 用户对资源进行评论
-(void)initWithUsersCommentOnResources :(NSString *)str
{
    __weak typeof(self) weakSelf = self;
    if([[_UserM usercode] isEqualToString:@""]){
        [weakSelf gotoLogin];
        return;
    }
    if ((NullStringjudgment(NSStr(str))).length == 0) {
        [self initWithtring:@"请输入您要评价的内容!"];
        return;
    }
    [LSZRequestData usersCommentOnResources:self.AllDynamicListsMg.id_id :@"" content:str :^(BOOL isOk, NSString * string, NSDictionary * dic) {
        if (isOk == YES) {
            weakSelf.uilabel.hidden = NO;
            weakSelf.textView.text = @"";
            [weakSelf initWithDynamicCommentDetailsWithPage:weakSelf.page];
            [weakSelf initWithtring:@"评价成功!"];
        }else{
            [weakSelf initWithtring:str];
        }
    }];
}
#pragma mark - 评论的长按
-(void)clickReport:(UILongPressGestureRecognizer *)lpGR
{
    if (lpGR.state == UIGestureRecognizerStateBegan) {//手势开始
        CGPoint point = [lpGR locationInView:self.tableViewAll];
        NSIndexPath *indexPath =  [self.tableViewAll indexPathForRowAtPoint:point];
        if (indexPath != nil){
            self.indexNum = indexPath.row;
//            NSLog(@"长按的是评价的第%ld区",self.indexNum);
        }
    }
    if (lpGR.state == UIGestureRecognizerStateEnded){
        //手势结束
        [self longPressDelete];//添加弹窗
    }
}
#pragma mark - 对评论举报点击事件
-(void)longPressDelete
{
    [self clickMoveReportWithWhat:@"1"];
}
#pragma mark - 对动态举报按钮的单击事件
-(void)clickMoveReport
{
    [self clickMoveReportWithWhat:@"0"];
}
-(void)clickMoveReportWithWhat:(NSString *)strWhat
{
    ACActionSheet *actionSheet = [[ACActionSheet alloc] initWithTitle:nil cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@[@"举报"] actionSheetBlock:^(NSInteger buttonIndex) {
        if (buttonIndex == 0) {
            if ([[_UserM usercode] isEqualToString:@""]) {
                pushAccLoginVC;
                return;
            }else{
                if ([strWhat isEqualToString:@"0"]) {
                    [self jumpOfReportInformation:self.AllDynamicListsMg.username titleString:self.AllDynamicListsMg.content tid:self.AllDynamicListsMg.id_id comment_id:@""];
                }else{
                    LSZDynamicCommentDetailsMg * manager = nil;
                    manager = self.mutArrayData[self.indexNum];
                    [self jumpOfReportInformation:manager.username titleString:manager.content tid:self.AllDynamicListsMg.id_id comment_id:manager.id_id];
                }
            }
        }
    }];
    [actionSheet show];
}
-(void)jumpOfReportInformation:(NSString *)name titleString:(NSString *)titleString tid:(NSString *)tid comment_id:(NSString *)comment_id
{
    LSZReportViewController * VC = [[LSZReportViewController alloc]init];
    VC.name = name;
    VC.titleString = titleString;
    VC.tid = tid;
    VC.type = @"1";
    VC.comment_id = comment_id;
    [self.navigationController pushViewController:VC animated:YES];
}
@end
